﻿@using HouseHoldBudget.App_GlobalResources
@using HouseHoldBudget.Models.Expenses
@using Kendo.Mvc.UI
@{
    ViewBag.Title = @CustomResources.ManageExpenseTypes_Title;
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="section-header">
    <div class="title">
        <img src="@Url.Content("~/Content/images/expenses.png")" alt="" />
        @CustomResources.Expenses_ManageExpenseTypesTitle
    </div>
</div>
<table class="content">
    <tr>
        <td>
            @(Html.Kendo().Grid<ExpenseTypesModel>()
               .Name("expenseTypes-grid")

                            .Columns(columns =>
                            {
                                columns.Command(commands =>
                                {
                                    commands.Edit();
                                    commands.Destroy();
                                }).Width(220);

                                columns.Bound(x => x.ExpenseTypeName)
                                    .Title("Nom");
                            })
                 .ToolBar(toolbar => toolbar.Create().Text("Ajouter un type de dépense"))
                 .Editable(editable => editable.Mode(Kendo.Mvc.UI.GridEditMode.InLine))
                 .DataSource(dataBinding => dataBinding.Ajax()
                                                .Model(model =>
                                                {
                                                    model.Id(p => p.Id);
                                                    model.Field(p => p.ExpenseTypeName);
                                                })
                                                .Read(read => read.Action("GetExpenseTypes", "Expenses"))
                                                .Create(create => create.Action("InsertExpenseType", "Expenses"))
                                                .Update(update => update.Action("UpdateExpenseType", "Expenses"))
                                                .Destroy(destroy => destroy.Action("DeleteExpenseType", "Expenses"))
                                                .PageSize(20))
                    .Scrollable()
                    .Sortable()
                    .Filterable())
        </td>
    </tr>
</table>
